-- <nowiki>
local T = require('Module:Tool')
local V = require('Module:Value')
local Header = require('Module:Template/Champion/Header')

return {
    render = function(frame)
        local args = T.parseArgs(frame)

        local champion = args.champion or args[2] or V.champion({[1] = args.slot or args[1], [2] = '~'})

        if champion == nil then
            return T.error(
                '[Template.Champion.Page.render().champion] is Nil: ' .. T.parseErrorValue(args.slot or arg[1])
            )
        end

        local result = ''

        result = result .. string.format('[[Category:%s年 英雄]]', string.sub(champion.release.date, 0, 4))
        result = result .. string.format('[[Category:国服/英雄/%s]]', champion.nameS)
        result = result .. string.format('[[Category:台服/英雄/%s]]', champion.nameT)
        result = result .. string.format('[[Category:国服/%s 金币英雄]]', champion.price.beS)
        result = result .. string.format('[[Category:国服/%s 点券英雄]]', champion.price.rpS)
        result = result .. string.format('[[Category:台服/%s 權力點英雄]]', champion.price.beT)
        result = result .. string.format('[[Category:台服/%s 聯盟幣英雄]]', champion.price.rpT)

        for _, slotRole in ipairs(champion.type.roles) do
            local role = V.glossary({slotRole, '~'})

            if type(role) == 'table' then
                result = result .. string.format('[[Category:国服/%s 英雄]]', role.nameS)
                result = result .. string.format('[[Category:台服/%s 英雄]]', role.nameT)
            end
        end

        local range = V.glossary({champion.type.range, '~'})

        if type(range) == 'table' then
            result = result .. string.format('[[Category:国服/%s 英雄]]', range.nameS)
            result = result .. string.format('[[Category:台服/%s 英雄]]', range.nameT)
        end

        result = result .. tostring(Header.render({champion = champion}))

        return result
    end
}
-- </nowiki>
-- [[Category:Module/Template]]
